package com.sc.nft.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sc.nft.entity.DigitalCollectionProductInfoSubscribeCode;
import com.sc.nft.entity.vo.DigitalCollectionProductInfoSubscribeCodeVo;
import com.sc.nft.entity.vo.SubscribeProductListVo;
import com.sc.nft.entity.vo.ProductIdAndMaxSubscribeByUserIdAndCountVO;
import com.sc.nft.enums.ProductInfoSubscribeScheduleEnum;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Set;

/**
 * 用户申购码(DigitalCollectionProductInfoSubscribeCode)表数据库访问层
 *
 * @author 王伟成
 * @since 2024-05-15 18:32:40
 */
public interface DigitalCollectionProductInfoSubscribeCodeMapper extends BaseMapper<DigitalCollectionProductInfoSubscribeCode> {

    Page<DigitalCollectionProductInfoSubscribeCodeVo> getSubscribeCodePage(Page page, @Param("firstTitle") String firstTitle,@Param("activityStatus") Integer activityStatus);

    Page<SubscribeProductListVo> getByProductIdLeft(@Param("userId") Long userId, Page page);

    /**
     * 抽签
     *
     * @param productId
     * @param sumCount
     */
    void drawLots(@Param("productId") Long productId, @Param("sumCount") Integer sumCount, @Param("excludeUserId") Set<Long>excludeUserId);
    /**
     * 获取多获取申购码的用户以及数量
     * @param productId
     * @param maxSubscribe
     * @return
     */
    List<ProductIdAndMaxSubscribeByUserIdAndCountVO> getProductIdAndMaxSubscribeByUserIdAndCount(@Param("productId") Long productId, @Param("maxSubscribe") Integer maxSubscribe, @Param("excludeUserId") Set<Long> excludeUserId);

    /**
     * 把本期中奖的数据copy到中签表,供给后面的人使用
     * @param productId
     */
    void toWinABallotCopyResult(@Param("productId") Long productId);
    /**
     * 把本期未中的,全部变成未中签
     * @param productId
     */
    void drawBlank(@Param("productId") Long productId);

    /**
     *
     * @param userId
     * @param productId
     * @param schedule
     * @return
     */
    Page<DigitalCollectionProductInfoSubscribeCode> getPageByUserProductIdAndSchedule(Page page, @Param("userId") Long userId, @Param("productId") Long productId, @Param("schedule") Integer schedule, @Param("consistenceEnd") Boolean consistenceEnd);

}
